#ifndef XM_LIN_H
#define XM_LIN_H


#define TERMACOOK_LIN		0


#if (TERMACOOK_LIN)

#define LIN_ID_CONTROL      0xA6
#define LIN_ID_SLAVE_P      0xF0
#define LIN_ID_MASTER       0x80

enum lin_state 
{
	IDLE, 
	_BREAK, 
	SYNCH, 
	PROTECTED_IDENTIFIER, 
	DATA0, 
	DATA1,
 	DATA2, 
	DATA3, 
	DATA4, 
	DATA5, 
	DATA6, 
	DATA7, 
	CHECKSUM 
};

typedef struct frame {
	unsigned char protected_id;
	unsigned char _data[8];
	unsigned char check;
	enum lin_state state;
	unsigned char error;
};

extern struct frame frame_receive;
extern unsigned char flag_receive_over;
extern unsigned char receive_len;

void INIT_LIN1(void);
unsigned char LINCalcParity(unsigned char id);
unsigned char LINCalcChecksum(unsigned char *__data, unsigned char __n); 
int LINSendChar(unsigned char ch);
int LIN1GetChar(void);


void lin_slave_deal(void);


#endif 

#endif

